<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>eos-Chain API</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="./plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="./plugins/layui/css/myPage.css">
</head>
<body style=" overflow-x:hidden;">
<div class=" layui-show">
    <div class="layui-container">
        <div class="layui-row">
            <div class="layui-col-md12">
                <fieldset class="layui-elem-field" style="margin-top: 20px;">
                    <legend>节点最新信息</legend>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">server_version</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="server_version" class="layui-input">
                        </div>
                        <label class="layui-form-label" style="width: 175px">head_block_num</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="head_block_num" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">last_irreversible_block_num</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="last_irreversible_block_num" class="layui-input">
                        </div>
                        <label class="layui-form-label" style="width: 175px">head_block_id</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="head_block_id" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">head_block_time</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="head_block_time" class="layui-input">
                        </div>
                        <label class="layui-form-label" style="width: 175px">head_block_producer</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="head_block_producer" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">recent_slots</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="recent_slots" class="layui-input">
                        </div>
                        <label class="layui-form-label" style="width: 175px">participation_rate</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="participation_rate" class="layui-input">
                        </div>
                    </div>
                </fieldset>
            </div>
        </div>
        <div class="layui-row ">
            <div class="layui-col-md12">
                <fieldset class="layui-elem-field" style="margin-top: 20px;">
                    <legend>查询块信息</legend>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">block_num_or_id</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="block_num_or_id" class="layui-input">
                        </div>
                        <button type="button" class="layui-btn layui-btn-normal" id="get_block">查询</button>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">previous</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="previous" class="layui-input">
                        </div>
                        <label class="layui-form-label" style="width: 175px">timestamp</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="timestamp" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">transaction_merkle_root</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="transaction_merkle_root" class="layui-input">
                        </div>
                        <label class="layui-form-label" style="width: 175px">producer</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="producer" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">producer_changes</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="producer_changes" class="layui-input">
                        </div>
                        <label class="layui-form-label" style="width: 175px">producer_signature</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="producer_signature" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">cycles</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="cycles" class="layui-input">
                        </div>
                        <label class="layui-form-label" style="width: 175px">id</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="id" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">block_num</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="block_num" class="layui-input">
                        </div>
                        <label class="layui-form-label" style="width: 175px">ref_block_prefix</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="ref_block_prefix" class="layui-input">
                        </div>
                    </div>
                </fieldset>
            </div>
        </div>
        <div class="layui-row ">
            <div class="layui-col-md12">
                <fieldset class="layui-elem-field" style="margin-top: 20px;">
                    <legend>获取账户信息</legend>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">name</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="name" class="layui-input">
                        </div>
                        <button type="button" class="layui-btn layui-btn-normal" id="get_account">查询</button>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">name</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="name1" class="layui-input">
                        </div>
                        <label class="layui-form-label" style="width: 175px">eos_balance</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="eos_balance" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">staked_balance</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="staked_balance" class="layui-input">
                        </div>
                        <label class="layui-form-label" style="width: 175px">unstaking_balance</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="unstaking_balance" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">last_unstaking_time</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="last_unstaking_time" class="layui-input">
                        </div>
                        <label class="layui-form-label" style="width: 175px">permissions</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="permissions" class="layui-input">
                        </div>
                    </div>
                </fieldset>
            </div>
        </div>
        <div class="layui-row ">
            <div class="layui-col-md12">
                <fieldset class="layui-elem-field" style="margin-top: 20px;">
                    <legend>获取智能合约</legend>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">account_name</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="account_name" class="layui-input">
                        </div>
                        <button type="button" class="layui-btn layui-btn-normal" id="get_code">查询</button>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">name</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="name2" class="layui-input">
                        </div>
                        <label class="layui-form-label" style="width: 175px">code_hash</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="code_hash" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">wast</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="wast" class="layui-input">
                        </div>
                        <label class="layui-form-label" style="width: 175px">abi</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="abi" class="layui-input">
                        </div>
                    </div>
                </fieldset>
            </div>
        </div>
        <div class="layui-row ">
            <div class="layui-col-md12">
                <fieldset class="layui-elem-field" style="margin-top: 20px;">
                    <legend>从账户获取智能合约数据</legend>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">scope</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="scope" class="layui-input">
                        </div>
                        <button type="button" class="layui-btn layui-btn-normal" id="get_table_rows">查询</button>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">account</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="account" class="layui-input">
                        </div>
                        <label class="layui-form-label" style="width: 175px">balance</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="balance" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">more</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="more" class="layui-input">
                        </div>
                    </div>
                </fieldset>
            </div>
        </div>
        <div class="layui-row ">
            <div class="layui-col-md12">
                <fieldset class="layui-elem-field" style="margin-top: 20px;">
                    <legend>将json序列化为二进制十六进制</legend>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">form</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="from" class="layui-input">
                        </div>
                        <label class="layui-form-label" style="width: 175px">to</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="to" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">quantity</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="quantity" class="layui-input">
                        </div>
                        <button type="button" class="layui-btn layui-btn-normal" id="abi_json_to_bin">转化</button>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">binargs</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="binargs" class="layui-input">
                        </div>
                        <label class="layui-form-label" style="width: 175px">required_scope</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="required_scope" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">required_auth</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="required_auth" class="layui-input">
                        </div>
                    </div>
                </fieldset>
            </div>
        </div>
        <div class="layui-row ">
            <div class="layui-col-md12">
                <fieldset class="layui-elem-field" style="margin-top: 20px;">
                    <legend>将二进制十六进制序列化为json</legend>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">binargs</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="binargs2" class="layui-input">
                        </div>
                        <button type="button" class="layui-btn layui-btn-normal" id="abi_bin_to_json">转化</button>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">from</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="from2" class="layui-input">
                        </div>
                        <label class="layui-form-label" style="width: 175px">to</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="to2" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">quantity</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="quantity2" class="layui-input">
                        </div>
                        <label class="layui-form-label" style="width: 175px">required_scope</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="required_scope2" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 175px">required_auth</label>
                        <div class="layui-input-inline" style="width: 350px;">
                            <input type="text" name="required_auth2" class="layui-input">
                        </div>
                    </div>
                </fieldset>
            </div>
        </div>
        <!--<div class="layui-row ">-->
            <!--<div class="layui-col-md12">-->
                <!--<fieldset class="layui-elem-field" style="margin-top: 20px;">-->
                    <!--<legend>车辆信息</legend>-->
                    <!--<div class="layui-form-item">-->
                        <!--<label class="layui-form-label" style="width: 175px">车牌号</label>-->
                        <!--<div class="layui-input-inline" style="width: 350px;">-->
                            <!--<input type="text" name="cph" class="layui-input">-->
                        <!--</div>-->
                        <!--<label class="layui-form-label" style="width: 175px">主(挂)车车号</label>-->
                        <!--<div class="layui-input-inline" style="width: 350px;">-->
                            <!--<input type="text" name="zgcch" class="layui-input">-->
                        <!--</div>-->
                    <!--</div>-->
                <!--</fieldset>-->
            <!--</div>-->
        <!--</div>-->
    </div>
</div>
<script src="./plugins/layui/layui.js"></script>
<script src="./js/config.js"></script>
<script type="text/javascript">
    layui.use(['table','form','element'],function () {
        var $ = layui.$;
        var table = layui.table;
        var form = layui.form;
        var element = layui.element;

        var jsonx = {};
        jsonx.yhm = "yang";
        jsonx.mima = "96e79218965eb72c92a549dd5a330112";
        $.ajax({
            url:"/apis/loginUser",
            type:"POST",
            contentType:"application/json;charset=utf-8",
            dataType:"json",
            data:JSON.stringify(jsonx),
            success: function(data){
                alert(data.message);
            },
            error: function(data){
                alert('fail');
            }
        });

        $.ajax({
            url: contextPath1+"chain/get_info",
            type: "GET",
            contentType:"application/json;charset=utf-8",
            dataType:"json",
            success: function(data) {
                $('input[name="server_version"]').attr("value",data.server_version);
                $('input[name="head_block_num"]').attr("value",data.head_block_num);
                $('input[name="last_irreversible_block_num"]').attr("value",data.last_irreversible_block_num);
                $('input[name="head_block_id"]').attr("value",data.head_block_id);
                $('input[name="head_block_time"]').attr("value",data.head_block_time);
                $('input[name="head_block_producer"]').attr("value",data.head_block_producer);
                $('input[name="recent_slots"]').attr("value",data.recent_slots);
                $('input[name="participation_rate"]').attr("value",data.participation_rate);
                // for(var i in data) {
                //     var body = $('body');
                //     body.contents().find("[name='" + i + "']").val(eval("data." + i));
                // }
            },
            error: function(data){
                alert('fails');
            }
        });

        $('#get_block').on('click',function (){
            var jsons = {};
            jsons.block_num_or_id = $('input[name="block_num_or_id"]').val();
            $.ajax({
                url: contextPath1+"chain/get_block",
                type: "POST",
                contentType:"application/json;charset=utf-8",
                dataType:"json",
                data:JSON.stringify(jsons),
                success:function (data) {
                    $('input[name="previous"]').attr("value",data.previous);
                    $('input[name="timestamp"]').attr("value",data.timestamp);
                    $('input[name="transaction_merkle_root"]').attr("value",data.transaction_merkle_root);
                    $('input[name="producer"]').attr("value",data.producer);
                    $('input[name="producer_changes"]').attr("value",data.producer_changes);
                    $('input[name="producer_signature"]').attr("value",data.producer_signature);
                    $('input[name="cycles"]').attr("value",data.cycles);
                    $('input[name="id"]').attr("value",data.id);
                    $('input[name="block_num"]').attr("value",data.block_num);
                    $('input[name="ref_block_prefix"]').attr("value",data.ref_block_prefix);
                },
                error:function () {
                }
            });
        });

        $('#get_account').on('click',function (){
            var jsons = {};
            jsons.name = $('input[name="name"]').val();
            $.ajax({
                url: contextPath1+"chain/get_account",
                type: "POST",
                contentType:"application/json;charset=utf-8",
                dataType:"json",
                data:JSON.stringify(jsons),
                success:function (data) {
                    $('input[name="name1"]').attr("value",data.name);
                    $('input[name="eos_balance"]').attr("value",data.eos_balance);
                    $('input[name="staked_balance"]').attr("value",data.staked_balance);
                    $('input[name="unstaking_balance"]').attr("value",data.unstaking_balance);
                    $('input[name="last_unstaking_time"]').attr("value",data.last_unstaking_time);
                    $('input[name="permissions"]').attr("value",data.permissions);
                },
                error:function () {
                }
            });
        });

        $('#get_code').on('click',function (){
            var jsons = {};
            jsons.account_name = $('input[name="account_name"]').val();
            $.ajax({
                url: contextPath1+"chain/get_code",
                type: "POST",
                contentType:"application/json;charset=utf-8",
                dataType:"json",
                data:JSON.stringify(jsons),
                success:function (data) {
                    $('input[name="name2"]').attr("value",data.name);
                    $('input[name="code_hash"]').attr("value",data.code_hash);
                    $('input[name="wast"]').attr("value",data.wast);
                    $('input[name="abi"]').attr("value",data.abi);
                },
                error:function () {
                }
            });
        });

        $('#get_table_rows').on('click',function (){
            var jsons = {};
            jsons.scope = $('input[name="scope"]').val();
            jsons.code = "currency";
            jsons.table = "account";
            jsons.json = true;
            $.ajax({
                url: contextPath1+"chain/get_table_rows",
                type: "POST",
                contentType:"application/json;charset=utf-8",
                dataType:"json",
                data:JSON.stringify(jsons),
                success:function (data) {
                    $('input[name="account"]').attr("value",data.rows.account);
                    $('input[name="balance"]').attr("value",data.rows.balance);
                    $('input[name="more"]').attr("value",data.more);
                },
                error:function () {
                }
            });
        });

        $('#abi_json_to_bin').on('click',function (){
            var jsons = {};
            jsons.code = "currency";
            jsons.action = "transfer";
            var args;
            args.from = $('input[name="from"]').val();
            args.to = $('input[name="to"]').val();
            args.quantity = $('input[name="quantity"]').val();
            jsons.args = args;
            $.ajax({
                url: contextPath1+"chain/abi_json_to_bin",
                type: "POST",
                contentType:"application/json;charset=utf-8",
                dataType:"json",
                data:JSON.stringify(jsons),
                success:function (data) {
                    $('input[name="binargs"]').attr("value",data.binargs);
                    $('input[name="required_scope"]').attr("value",data.required_scope);
                    $('input[name="required_auth"]').attr("value",data.required_auth);
                },
                error:function () {
                }
            });
        });

        $('#abi_bin_to_json').on('click',function (){
            var jsons = {};
            jsons.code = "currency";
            jsons.action = "transfer";
            jsons.binargs = $('input[name="binargs2"]').val();
            $.ajax({
                url: contextPath1+"chain/abi_bin_to_json",
                type: "POST",
                contentType:"application/json;charset=utf-8",
                dataType:"json",
                data:JSON.stringify(jsons),
                success:function (data) {
                    $('input[name="from2"]').attr("value",data.args.from);
                    $('input[name="to2"]').attr("value",data.args.to);
                    $('input[name="quantity2"]').attr("value",data.args.quantity);
                    $('input[name="required_scope2"]').attr("value",data.required_scope);
                    $('input[name="required_auth2"]').attr("value",data.required_auth);
                },
                error:function () {
                }
            });
        });

        return false;
    });
</script>
</body>
</html>